package com.ass.wechat.service;

import java.util.ArrayList;
import java.util.List;
import java.util.Properties;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.ass.common.utils.RandomUtil;
import com.ass.common.utils.StringUtil;
import com.ass.wechat.message.respdto.Article;
import com.ass.wechat.message.respdto.NewsMessageResp;


@Service
public class PicServiceImpl implements PicService {

	
	@Resource
	private Properties wechatProperties;
	
//	<prop key="urlOfShowPic">${urlOfShowPic}</prop>
//	<prop key="picOfBiyezhaoUrl">${picOfBiyezhaoUrl}</prop>
//	<prop key="picEnd">${picEnd}</prop>
	@Override
	public NewsMessageResp getBiYeZhao(NewsMessageResp newsMessageResp) {
		
		
		List<Article> arLst = new ArrayList<Article>();
		
		
		Article a1 = new Article();
		a1.setTitle("");
		a1.setDescription("点击查看大图~");
		int ran = RandomUtil.getRandom(StringUtil.getString(wechatProperties.get("biyezhaoNum")));
		String picSrc = wechatProperties.getProperty("picOfBiyezhaoUrl")
						+ran
							+wechatProperties.getProperty("picEnd");
		a1.setPicUrl(picSrc);
		//http://mamba10.xicp.net/wechat/jsp/forPicShowJsp.jsp?src=http://userhead-and-dynamicpics.oss-cn-hangzhou.aliyuncs.com/pic/dynamicImage/1389625146221.gif
		a1.setUrl(wechatProperties.getProperty("urlOfShowPic")+"?src="+picSrc);
		
		
		arLst.add(a1);
		newsMessageResp.setArticles(arLst);
		newsMessageResp.setArticleCount(StringUtil.getString(arLst.size()));
		
		return newsMessageResp;
	}

}
